package com.artron.mediaartron.data.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.artron.mediaartron.data.production.FrameConstant;

import static android.R.attr.type;

/**
 * Class description here
 *
 * @author doing
 * @version 1.0.0
 * @since 2017-09-22.
 */

public class FrameData implements Parcelable {

    private String title;

    private int price;

    private ImageData image;

    private String size;

    private float height;

    private float width;

    private String shapeType;

    private String sku;

    private float pagerHeight;

    private int number = 1;

    private int type;

    public FrameData(int price, String size, int height, int width, String sku) {
        this.price = price;
        this.size = size;
        this.height = height;
        this.width = width;
        this.sku = sku;
    }

    private FrameData(int price, ImageData image, String size, float height,
                      float width, String shapeType, String sku, int type) {
        this.price = price;
        this.image = image;
        this.size = size;
        this.height = height;
        this.width = width;
        this.shapeType = shapeType;
        this.sku = sku;
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public float getPagerHeight() {
        return pagerHeight;
    }

    public void setPagerHeight(float pagerHeight) {
        this.pagerHeight = pagerHeight;
    }

    public FrameData(String shapeType) {
        this.shapeType = shapeType;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public ImageData getImage() {
        return image;
    }

    public void setImage(ImageData image) {
        this.image = image;
    }

    public String getSize() {
        return size;
    }

    public String getShowSize() {
        return size + "mm";
    }

    public void setSize(String size) {
        this.size = size;
    }

    public float getHeight() {
        return height;
    }

    public void setHeight(float height) {
        this.height = height;
    }

    public float getWidth() {
        return width;
    }

    public void setWidth(float width) {
        this.width = width;
    }

    public String getShapeType() {
        return shapeType;
    }

    public void setShapeType(String shapeType) {
        this.shapeType = shapeType;
    }

    public String getSku() {
        return sku;
    }

    public void setSku(String sku) {
        this.sku = sku;
    }

    public FrameData copy() {
        return new FrameData(price, image, size
                , height, width, shapeType, sku, type);
    }

    public void setRightSku(int position) {
        if (this.sku.contains(",")) {
            sku = sku.split(",")[position];
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.title);
        dest.writeInt(this.price);
        dest.writeParcelable(this.image, flags);
        dest.writeString(this.size);
        dest.writeFloat(this.height);
        dest.writeFloat(this.width);
        dest.writeString(this.shapeType);
        dest.writeString(this.sku);
        dest.writeFloat(this.pagerHeight);
        dest.writeInt(this.number);
        dest.writeInt(this.type);
    }

    protected FrameData(Parcel in) {
        this.title = in.readString();
        this.price = in.readInt();
        this.image = in.readParcelable(ImageData.class.getClassLoader());
        this.size = in.readString();
        this.height = in.readFloat();
        this.width = in.readFloat();
        this.shapeType = in.readString();
        this.sku = in.readString();
        this.pagerHeight = in.readFloat();
        this.number = in.readInt();
        this.type = in.readInt();
    }

    public static final Parcelable.Creator<FrameData> CREATOR = new Parcelable.Creator<FrameData>() {
        @Override
        public FrameData createFromParcel(Parcel source) {
            return new FrameData(source);
        }

        @Override
        public FrameData[] newArray(int size) {
            return new FrameData[size];
        }
    };
}
